<php>if(!$isLoadScript){</php>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/lib/webuploader/js/webuploader.js"></script>
<link href="__PUBLIC__/lib/webuploader/css/webuploader.css" type="text/css" rel="stylesheet">
<php>}</php>
<div class="controls singleImage">
    <div class="col-md-9" style="padding-bottom: 5px;"><span id="web_uploader_wrapper_{$id}" class="btn btn-info btn-raised btn-sm">上传</span><span class="btn btn-info btn-raised btn-sm" data-toggle="modal" data-target="#attachmentModal">选择图片</span></div>
    <input id="web_uploader_input_{$id}" class="attach" name="{$name}" type="hidden" value="{$value}" event-args="{$args}" event-node="uploadinput">
    <div class="upload-img-box">

        <div id="web_uploader_picture_{$id}" class="web_uploader_picture">
            <notempty name="value">
                <div class="each">
                <a href="{$value|get_cover='path'}" title="点击查看大图">
                    <img src="{$value|get_cover='path'}">
                </a>
                <div class="text-center opacity del_btn" ></div>
                <div onclick="admin_image.removeImage($(this),'{$value}')"  class="text-center del_btn">删除</div>
                </div>
            </notempty>

            <div class="text-center opacity del_btn width"></div>
        </div>

    </div>

</div>
                <!--附件列表模态框-->
            <div class="modal fade" id="attachmentModal" tabindex="-1" role="dialog" aria-labelledby="attachmentModalLabel">
                  <div class="modal-dialog">
                    <div class="modal-content">
                      <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title tc">图片选择器</h4>
                      </div>
                      <div class="modal-body">
                        {:W('Common/Attachment/lists',array($field))}
                      </div>
                    </div><!-- /.modal-content -->
                  </div><!-- /.modal-dialog -->
                </div><!-- /.modal -->
<script>
    $(function () {
        var id = "#web_uploader_wrapper_{$id}";
        var uploader_{$id}  = WebUploader.create({
            // 选完文件后，是否自动上传。
            auto: true,
            // swf文件路径
            swf: 'Uploader.swf',
            // 文件接收服务端。
            server: U('Admin/Attachment/uploadPicture'),
            fileNumLimit: 5,
            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: {'id': id, 'multi': false},
            // 只允许选择图片文件
            accept: {
                title: 'Images',
                extensions: 'gif,jpg,jpeg,bmp,png',
                mimeTypes: 'image/*'
            }
        });
        uploader_{$id}.on('fileQueued', function (file) {
            uploader_{$id}.upload();
            $("#web_uploader_file_name_{$id}").text('正在上传...');
        });

        /*上传成功*/
        uploader_{$id}.on('uploadSuccess', function (file, data) {
            if(data.status){
                $('#web_uploader_input_{$id}').focus();
                $('#web_uploader_input_{$id}').val(data.id);
                $('#web_uploader_input_{$id}').blur();

                $("#web_uploader_picture_{$id}").html('<div class="each"><a href="'+ _ROOT_+data.path+'" title="点击查看大图片"><img src="' + _ROOT_+data.path + '"/></a><div class="text-center opacity del_btn" ></div><div onclick="admin_image.removeImage($(this),'+data.id+')"  class="text-center del_btn">删除</div></div>');
            }else{
                $("#web_uploader_file_name_{$id}").text(data.info);
                updateAlert(data.info);
            }
        });
    });

</script>